<template>
  <div style="width:800px;">
    <div>
      <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign" style="width: 330px;margin-top:-60px">
        <p style="margin-left:-15px">密码登录</p>
        <el-input v-model="formLabelAlign.username" placeholder="用户名"></el-input>
        <el-input v-model="formLabelAlign.password" placeholder="密码" type="password"></el-input>
        <el-link type="info" @click="registerButton" style="float:left;margin-left:1px;margin-top:-15px">去注册</el-link>
        <el-link type="info" style="margin-left: 260px;margin-top:-125px">忘记密码?</el-link>
        <el-button type="primary" style="width: 330px;float:left;margin-top:-70px" @click="loginButton">登录</el-button>
      </el-form>
    </div>
    <!--注册-->
    <el-dialog title="卷!刷题网" :visible.sync="registerFormVisible" style="width: 920px;height:900px;margin-left:450px;
     margin-top: -80px;overflow: hidden" >
      <!--register是定义的组件-->
      <register></register>
    </el-dialog>
  </div>
</template>

<script>

import register from "@/components/register";

export default {
  name: "login",
  components: {
    register
  },
  data(){
    return {
      labelPosition: 'left',
      formLabelAlign: {
        username: '',
        password: ''
      },
      registerFormVisible: false,
      see:true
    };
  },
  methods:{
    registerButton:function(){
      /*this.$router.replace("/register")*/
      this.registerFormVisible=true;

    },
    loginButton(){
      /*request.post("/login/go",this.formLabelAlign).then(resp=>{
        //store包里的index,js
        //将token信息保存
        this.$store.commit("SET_TOKEN",resp.data.data.token);
        this.$store.commit("SET_USERINFO",resp.data.data.generalUser);
       console.log(resp)
     })*/
      this.$axios.post("/api/login/go",this.formLabelAlign).then(resp=>{
        //store包里的index,js
        //将token信息保存
        this.$store.commit("SET_TOKEN",resp.data.data.token);
        //this.$store.commit("SET_USERINFO",resp.data.data.user);
        this.$router.replace("/index/frontPage");
        console.log(resp)
      })

    }
  }
}
</script>

<style scoped>

</style>